class ProductContactsController < ApplicationController
  # GET /prodcut_contacts
  # GET /prodcut_contacts.xml
  def index
    @prodcut_contacts = ProductContact.find_all_by_product_id(params[:product_id]).paginate(:page => params[:page],
                    :per_page => 2)

    @product_contact = ProductContact.new({:product_id => params[:product_id]})
    @product = Product.find(params[:product_id])
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @prodcut_contacts }
    end
  end


  # GET /prodcut_contacts/new
  # GET /prodcut_contacts/new.xml
  def new
    @prodcut_contact = ProductContact.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @prodcut_contact }
    end
  end


  # POST /prodcut_contacts
  # POST /prodcut_contacts.xml
  def create
    @prodcut_contact = ProductContact.new(params[:product_contact])
    @prodcut_contact.product_id = params[:product_id]
    respond_to do |format|
      if @prodcut_contact.save
        flash[:notice] = 'ProdcutContact was successfully created.'
        format.html { redirect_to product_product_contacts_path(params[:product_id]) }
        format.xml  { render :xml => @prodcut_contact, :status => :created, :location => @prodcut_contact }
      else
        format.html { render new_product_product_contact_path( @prodcut_contact.product, @prodcut_contact) }
        format.xml  { render :xml => @prodcut_contact.errors, :status => :unprocessable_entity }
      end
    end
  end


end
